#!/usr/bin/env python

# override the default reporting of coords

import warnings
warnings.filterwarnings("ignore")
import pylab as pl
#from numpy import mean,histogram,arange
import scipy.stats as ssts
import scipy.optimize as sop
from scipy import linspace, array, log, arange
import sys

import mpl_toolkits.mplot3d as p3
import matplotlib.pyplot as plt

#from matplotlib import *

dbfile = sys.argv[1]
f = open(dbfile,"r")
counter = 0
x = []
y = []
z = []
coo = {}
for line in f:
    counter += 1
    if counter == 5:
        things = line.split("|")
        for t in range(len(things)):
            things[t] = things[t].strip()
    if counter >= 7 and not line.startswith("["):
        coords = line.split(" ")
        for i in range(len(coords)):
            if i not in coo:
                coo[i] = []
            if coords[i] != "\n":
                #print coords[i]
                coo[i].append(float(coords[i]))

x = coo[0]
y = coo[2]
z = coo[4]
#xmean = max(x)
#for i in range(len(x)):
#    x[i] = x[i]/xmean
#ymean = max(y)
#for i in range(len(y)):
#    y[i] = y[i]/ymean

#color = ['b','g','r','c','m','y','k','w']
color = ['g']
#ax = subplot(111)
leg=[]
#dimensions = range(0,len(coo)-1)
dimensions = [0]#,1,2,3,4]


#ax = p3.Axes3D(fig)

xss = {}
yss = {}
nss = {}
proms = {}
fig = plt.figure()
ax1 = fig.add_subplot(111)
for i in dimensions:
	if sum(coo[i]) != 0:
		

		#print "-->",i,len(coo[i])
		#print x0,fk.integrate_box_1d(min(coo[i]),x0)
		#print x1,fk.integrate_box_1d(min(coo[i]),x1)
		
		

		#print coo[i]
		l2 = pl.hist(coo[i],bins=10,histtype='step',normed=False, ec=color[i%len(color)],ls='dotted')
		print l2
		#l2 = pl.hist(coo[i],bins=len(coo[i]),histtype='step',normed=False, ec='#BFBFBF',ls='dotted')
		#l4 = pl.plot(xk,yk,'red')
		
	else:
		print "-->",i
pl.xlabel("Coordinate Value")
pl.ylabel("Hits")
pl.savefig(str(i)+"-dim.eps")

pl.show()
